import fetch from 'isomorphic-fetch';
import * as types from '../types'

const getData = (commit , str , callBack)=>{
    console.log(str)
    fetch(str,
                {
                    method: "GET",
                    mode: "cors",
                    headers: {
                        'Accept': 'application/json',
                        'Content-Type': 'application/json',
                    }
                }
            ).then(
                function (response) {
                    if (response.status !== 200) {
                        console.log('当前状态码为： ' + response.status);
                        return null;   //测试不存在这种情况 先不管
                    }

                    response.json().then(function (data) {
                        
                       callBack(commit,data)
                    });
                }
                )
                .catch(function (err) {
                    console.log('Fetch Error :-S', err);
                });
 }

export default getData;